extends PropertyFindSetter


class_name FloatSetter
"""
用于修改PropertyComponent数据的组件
"""


## 操作符
@export_enum("=", "+=", "-=", "*=", "/=") var operation: String = "="
## 操作数
@export var value: float = 0


func __calc_value(op: String, src_v: float, op_v: float) -> float:
    match op:
        "=": return op_v
        "+=": return src_v + op_v
        "-=": return src_v - op_v
        "*=": return src_v * op_v
        "/=": return src_v / op_v
    # 无法匹配, 不做修改
    return src_v

func __get_update_value(w: Object, p: String) -> Variant:
    return __calc_value(operation, w.get(p), value)
